package com.rainwood.material.adapter;

import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.rainwood.material.R;
import com.rainwood.material.bean.MarterialDetial;

import java.util.List;

/**
 * @auther : hhx
 * @date :  2021/3/5
 * @des :
 */
public class CheckInAdapter extends RecyclerView.Adapter<CheckInAdapter.ViewHolder> {
    private List<MarterialDetial> marterialDetials;

    public void setMarterialDetials(List<MarterialDetial> marterialDetials) {
        this.marterialDetials = marterialDetials;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View inflate = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_check_in, parent, false);
        return new ViewHolder(inflate);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        MarterialDetial detial = marterialDetials.get(position);
        holder.tvUserName.setText(detial.getUserName());
        holder.tvUserDept.setText(detial.getDepartmentName());
        holder.tvMaterialType.setText(detial.getMaterialType());
        holder.tvOneType.setText(detial.getFirstClassification());
        holder.tvTwoType.setText(detial.getSecondClassification());
        holder.tvMaterCode.setText(detial.getNo());
        holder.tvMaterName.setText(detial.getName());
        holder.tvMaterModel.setText(detial.getSize());
        holder.tvBackRemark.setText(detial.getBackRemarks());
        holder.tvInRemark.setText(detial.getCollectRemarks());
        holder.tvMaterCount.setText(detial.getQuantity());
        holder.tvBackCount.setText(detial.getReturnNum());

    }

    @Override
    public int getItemCount() {
        return marterialDetials.size();
    }

    class ViewHolder extends RecyclerView.ViewHolder {
        TextView tvUserName;
        TextView tvUserDept;
        TextView tvMaterState;
        TextView tvMaterialType;
        TextView tvOneType;
        TextView tvTwoType;
        TextView tvMaterCode;
        TextView tvMaterName;
        TextView tvMaterModel;
        TextView tvInRemark;
        TextView tvMaterCount;
        TextView tvBackCount;
        TextView tvBackRemark;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);

            tvUserName = (TextView) itemView.findViewById(R.id.tv_user_name);
            tvUserDept = (TextView) itemView.findViewById(R.id.tv_user_dept);
            tvMaterState = (TextView) itemView.findViewById(R.id.tv_mater_state);
            tvMaterialType = (TextView) itemView.findViewById(R.id.tv_material_type);
            tvOneType = (TextView) itemView.findViewById(R.id.tv_one_type);
            tvTwoType = (TextView) itemView.findViewById(R.id.tv_two_type);
            tvMaterCode = (TextView) itemView.findViewById(R.id.tv_mater_code);
            tvMaterName = (TextView) itemView.findViewById(R.id.tv_mater_name);
            tvMaterModel = (TextView) itemView.findViewById(R.id.tv_mater_model);
            tvInRemark = (TextView) itemView.findViewById(R.id.tv_in_remark);
            tvMaterCount = (TextView) itemView.findViewById(R.id.tv_mater_count);
            tvBackCount = (TextView) itemView.findViewById(R.id.tv_back_count);
            tvBackRemark = (TextView) itemView.findViewById(R.id.tv_back_remark);


        }
    }
}
